extends layout

block content
  h1= title
  div#page-wrapper
    div#page-inner
        div.row
         if(!login)
            div.col-md-6.col-sm-12.col-xs-12
                div.panel.panel-default
                    div.panel-heading
                      
                        label 您尚未登陸
                        a(href="/login") 請登陸或者注冊 #{loginCount}
          
         div.row
                div.col-md-6.col-sm-12.col-xs-12
                    if (login)
                      div.panel.panel-default
                        div.panel-heading
                                div.panel-heading 配件信息
                                    div.panel-body
                                        div.row
                                            form(action="/search_goods",method="post")
                                             div.row
                                                div.col-sm-2
                                                    label 类别
                                                div.col-sm-4
                                                    select(name="category")
                                                     option 适用车型
                                                     option 配件名称
                                                     option 产地
                                                     option 库存状态
                                                     option 有优惠单位
                                                     option 进价
                                                     option 零件号
                                                     option 物料号
                                                     option 条码号
                                                     option 上次进货日期
                                             div.row
                                                div.col-sm-2
                                                    label 关键字
                                                div.col-sm-4
                                                    input.form-control(name="keyword",placeholder="IP")
                                            
                                             div.form-group
                                                button(type="submit").btn.btn-default 搜索
         div.row
                div.col-md-6.col-sm-12.col-xs-12
                    if (login)
                      div.panel.panel-default
                        div.panel-heading 配件信息列表
                            button(type="submit",onclick="location='/add_goods'").btn.btn-default 添加配件
                        div.panel-body
                         div.row
                            div.col-md-1200.col-sm-1200.col-xs-1200
                             div.panel.panel-default
                                 table.table-striped.table-bordered.table-hover(border="4px",cellspacing="5px",cellpadding="5px")
                                    tr
                                    if (heads)
                                     for left_head in heads
                                        th #{left_head}
                                    if (datas)
                                     for item in datas
                                      tr
                                        for data in item.values
                                         td #{data.value}
                                        td
                                         button(type="submit",onclick="do_look(#{item.unqiue_tag})").btn.btn-default 查看
                                         button(type="submit",onclick="do_add(#{item.unqiue_tag})").btn.btn-default 更改

    script.
        function do_notify()
        {
            var data={
                CONTROL:"notice",
                CONTENT:$("#notify_content").val(),
                S_IP:$("#s_ip").val(),
                S_PORT:$("#s_port").val()
            };
            console.log($("#notify_content").val());
            $.post("/smanager", data, function (data, status) {
                console.log(data, status);
                var o = JSON.parse(data);
                console.log(o.message);
                $("#result").val(o.message);
            });
        }
        function Post(url,args){
            var body = $(document.body),
            form = $("<form method='post'></form>"),
            input;
            form.attr({"action":url});
            $.each(args,function(key,value){
                input = $("<input type='hidden'>");
                input.attr({"name":key});
                input.val(value);
                form.append(input);
            });

            form.appendTo(document.body);
            form.submit();
            document.body.removeChild(form[0]);
        }

        function do_add(unqiue_tag)
        {
            Post('/edit_goods',{unqiue_tag:unqiue_tag});
        }
        function do_look(unqiue_tag){
            Post('/look_goods_image',{unqiue_tag:unqiue_tag});
        }